package org.thunms.change.initialize.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.thunms.change.initialize.model.DataInitializeScript;
import org.thunms.change.initialize.service.DataInitializeScriptService;
import org.thunms.framework.controller.ControllerDefault;
import org.thunms.framework.model.DataGrid;
import org.thunms.framework.model.DataGridJson;
import org.thunms.framework.model.Json;
/**
 * 资源转换平台
 * 数据初始子系统
 * 数据初始脚本
 */
@Controller
@RequestMapping("/change/initialize/dataInitializeScript")
public class DataInitializeScriptController extends ControllerDefault {
	private static final long serialVersionUID = 1761664585416628119L;
	private static final Logger logger =LoggerFactory.getLogger(DataInitializeScriptController.class);

	public DataInitializeScriptController() {
		super("change", "initialize", "dataInitializeScript");
		logger.debug("执行模块初始化"+this.getRerutnURL(""));
	}
	
	@Autowired
	private DataInitializeScriptService dataInitializeScriptService;

	
	@RequestMapping(value = "/dataGridList")
	@ResponseBody
	public DataGridJson<DataInitializeScript> dataGridList(DataGrid dg, DataInitializeScript mode) {
		return this.dataInitializeScriptService.getDataGridList(dg, mode);
	}
	@RequestMapping(value = "/execute")
	@ResponseBody
	public Json execute(String ids){
		Json msg=new Json();
		if(dataInitializeScriptService.execute(ids)){
			msg.setMsg("脚本执行成功");
			msg.setSuccess(true);
		}else{
			msg.setMsg("脚本执行失败");
			msg.setSuccess(false);
		}
		
		return msg;
		
	}

}
